<template>
  <div>
      <input type="date" placeholder="输入你的生日" v-model="date">
      <br><br>
      点击按钮就能知道到目前为止你一共活了多少天<button @click="days">我是按钮</button>
      <p>{{day.toFixed(0)}}天</p>
  </div>
</template>

<script>
export default {
    data(){
        return {
            date:'',
            day:0
        }
    },
    methods:{
        days(){
            let old=+new Date(this.date)
            // console.log(old);
            let now =+new Date()
            if(now<old){
                return alert('时间还没到哦')
            }
            let total=(now-old)/1000/86400
            this.day=total
        }
        
    }
}
</script>

<style>

</style>